/* GUI CONVERTED from rcrqmmta.p (converter v1.76) Wed May 22 11:22:27 2002 */
/* rcrqmmta.p - Release Management Customer Schedules                         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.7.1.4 $                                                       */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 8.6    LAST MODIFIED: 09/20/96           BY: TSI *K005*          */
/* REVISION: 8.6    LAST MODIFIED: 04/23/97  BY: *K0C7* Verghese Kurien       */
/* REVISION: 8.6    LAST MODIFIED: 09/23/97  BY: *K0J8* Jean Miller           */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98  BY: *L007* A. Rahane             */
/* REVISION: 8.6E   LAST MODIFIED: 05/20/98  BY: *K1Q4* Alfred Tan            */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98  BY: *J314* Alfred Tan            */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00  BY: *N08T* Annasaheb Rahane      */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00  BY: *N0KP* Mark Brown            */
/* REVISION: 9.1    LAST MODIFIED: 09/04/00  BY: *N0RB* BalbeerS Rajput       */
/* $Revision: 1.7.1.4 $   BY: Jean Miller        DATE: 05/10/02  ECO: *P05V*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

/*INPUT PARAMETERS*/
define input parameter w_rqm_cat as character no-undo.
define input parameter w_rqm_value as character no-undo.
define input parameter schddet_recid as recid no-undo.

/*OUTPUT PARAMETERS*/
define output parameter rqmdet_recid as recid.
define output parameter errors as logical no-undo.

/*INPUT VARIABLES*/
define shared frame b.
define shared variable where_we_are as integer no-undo.

/*LOCAL VARIABLES*/
define variable i as integer no-undo.
define variable errlevel as integer no-undo.
define variable errgen like mfc_logical no-undo.
define variable append_msg as character no-undo.
define variable hrqmdet_recid as recid no-undo.
define variable v_rqmdet_recid as recid no-undo.
define variable schedule_type as character extent 3.

assign
   schedule_type[1] = " " + getTermLabel("CUSTOMER_PLAN_SCHEDULE",35)
   + " "
   schedule_type[2] = " " + getTermLabel("CUSTOMER_SHIP_SCHEDULE",35)
   + " "
   schedule_type[3] = " " + getTermLabel("REQUIRED_SHIP_SCHEDULE",35)
   + " ".

/*V8:EditableDownFrame=b */
FORM /*GUI*/ 
   rqm_det.rqm_cat
   rqm_value
with frame b title color normal (getFrameTitle("REQUIREMENTS_MAINTENANCE",34))
width 80 8 down scroll 1 no-validate THREE-D /*GUI*/.


/* SET EXTERNAL LABELS */
setFrameLabels(frame b:handle).

find schd_det where recid(schd_det) = schddet_recid no-lock.

find sod_det where sod_nbr = schd_nbr
               and sod_line = schd_line
no-lock.

find so_mstr where so_nbr = schd_nbr no-lock.

assign
   hrqmdet_recid = rqmdet_recid
   errors = true.

if w_rqm_cat = "AUTHNBR" then
authnbr-loop:
do on error undo, retry on endkey undo, leave:
/*GUI*/ if global-beam-me-up then undo, leave.


   /********************************************************/
   /* CHECK FOR LINKS TO CONFIRMED AND UNCONFIRMED         */
   /* SHIPPERS.                                            */
   /********************************************************/
   {gprun.i ""rcscmtc.p""
      "(input recid(schd_det),
        output errgen)"}
/*GUI*/ if global-beam-me-up then undo, leave.


   if errgen then
      undo, return.

   if so_auth_days = 0 then
      leave authnbr-loop.

   /*CHECK FOR DUPLICATE AUTHORIZATION NUMBER*/
   {gprun.i ""rcrqmval.p""
      "(input so_ship,
        input schd_date - so_auth_days,
        input w_rqm_value,
        input schd_type,
        output v_rqmdet_recid)"}
/*GUI*/ if global-beam-me-up then undo, leave.


   if v_rqmdet_recid <> ? then do:

      find rqm_det where recid(rqm_det) = v_rqmdet_recid
      no-lock.

      append_msg = string(rqm_type) + "/" +
                   string(rqm_line) + "/" + rqm_rlse_id + "/" +
                   string(rqm_date,"99-99-99") + "/" +
                   string(rqm_time,"99:99") + "/" +
                   rqm_value.

      /* Duplicate AUTHNBR in Type/Rel/Date/Time/Value */
      {pxmsg.i &MSGNUM=1514 &ERRORLEVEL=3 &MSGARG1=append_msg}

      return.

   end.
end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* if input rqm_cat = "AUTHNBR" */

/* Creating new record */
{pxmsg.i &MSGNUM=1 &ERRORLEVEL=1}

create rqm_det.
assign
   rqm_type = schd_type
   rqm_nbr = schd_nbr
   rqm_line = schd_line
   rqm_rlse_id = schd_rlse_id
   rqm_date = schd_date
   rqm_time = schd_time
   rqm_interval = schd_interval
   rqm_reference = schd_reference
   rqm_det.rqm_cat = w_rqm_cat
   rqm_value = w_rqm_value.

if recid(rqm_det) = -1 then.

if not ({gpcode.v rqm_cat}) then do:

   if rqm_det.rqm_cat = "AUTHNBR" then do:

      create code_mstr.
      assign
         code_cmmt = getTermLabel("REQUIREMENT_DET_AUTHORIZATION_NBR",40)
         code_fldname = "rqm_cat"
         code_value = "AUTHNBR".

      if recid(code_mstr) = -1 then.

   end.
   else do:
      /* Value must exist in generalized codes */
      {pxmsg.i &MSGNUM=716 &ERRORLEVEL=3}
      undo, return.
   end.
end.

rqmdet_recid = recid(rqm_det).

find rqm_det where recid(rqm_det) = rqmdet_recid
exclusive-lock.

do i = 1 to frame-line(b) while available rqm_det:
   find prev rqm_det
      where rqm_type      = schd_type
      and rqm_nbr       = schd_nbr
      and rqm_line      = schd_line
      and rqm_rlse_id   = schd_rlse_id
      and rqm_date      = schd_date
      and rqm_time      = schd_time
      and rqm_interval  = schd_interval
      and rqm_reference = schd_reference
   no-lock no-error.
end.

up frame-line(b) - 1 with frame b.

do i = 1 to frame-down(b) with frame b:
   find next rqm_det
      where rqm_type      = schd_type
      and rqm_nbr       = schd_nbr
      and rqm_line      = schd_line
      and rqm_rlse_id   = schd_rlse_id
      and rqm_date      = schd_date
      and rqm_time      = schd_time
      and rqm_interval  = schd_interval
      and rqm_reference = schd_reference
   no-lock no-error.

   if available rqm_det then do:

      display
         rqm_det.rqm_cat
         rqm_value.

      if recid(rqm_det) = rqmdet_recid then
         where_we_are = frame-line.

   end.

   else clear frame b no-pause.

   if i < frame-down then down 1.

end. /* do i = 1 to frame-down */

up frame-line(b) - where_we_are with frame b.

if available rqm_det then
   display
      rqm_det.rqm_cat
      rqm_value
   with frame b.

errors = false.
